﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.RB
{
    class Class9
    {
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            string s = ppa.PolicyActing.Policy.SelectedColRateFactors["领取时间"];

            int a = int.Parse(s.Substring(0, 2));

            if (ppa.Period > 0 && ppa.Period % 3 == 0 && ppa.Age<a)
            {
                int b = ppa.Period / 3;

                double c = ppa.Amount * 0.15 + ppa.Amount * 0.03 * b;

                da.Value = c > ppa.Amount * 0.3 ? ppa.Amount * 0.3 : c;

            }else if (ppa.Age >= a)
            {
                da.Value = ppa.Amount * 0.1;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            string s = ppa.PolicyActing.Policy.SelectedColRateFactors["领取时间"];

            int a = int.Parse(s.Substring(0, 2));

            if (ppa.Period > 0 && ppa.Period % 3 == 0 && ppa.Age < a)
            {
                da.Value = ppa.PolicyActing.Policy.Fee * 0.02;

            }
 
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            string s = ppa.PolicyActing.Policy.SelectedColRateFactors["领取时间"];

            int a = int.Parse(s.Substring(0, 2));

            if (ppa.Age==a)
            {
                da.Value = ppa.TotalFee;

            }

        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {

                string s = ppa.PolicyActing.Policy.SelectedColRateFactors["领取时间"];

                int a = int.Parse(s.Substring(0, 2));

                if (ppa.Age < 18)
                {
                    da.Value = ppa.TotalFee;
                }
                else if (ppa.Age < a && ppa.Period == 0)
                {
                    da.Value = ppa.TotalFee;
                }
                else if (ppa.Age < a && ppa.Period > 0)
                {
                    da.Value = ppa.TotalFee * 1.05;
                }
                else
                {
                    da.Value = ppa.Amount;
                }
                ppa.IsCurrentFinish = true;
            }
        }
    }
}
